# $Id$
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=p11-kit
pkgver=0.23.14
pkgrel=1
pkgdesc="Provides a way to load and enumerate PKCS#11 modules"
arch=(x86_64)
url="https://p11-glue.freedesktop.org"
license=(BSD)
depends=(glibc libtasn1 libffi libsystemd)
makedepends=(gtk-doc git)
install=p11-kit.install
source=("git+https://github.com/p11-glue/p11-kit?signed#tag=$pkgver"
        0001-Build-and-install-libnssckbi-p11-kit.so.patch)
sha256sums=('SKIP'
            '0736f74cec5ca49d91afa47cd84f9ac0404947bf0064358e22c3e53b69e82798')
validpgpkeys=('C0F67099B808FB063E2C81117BFB1108D92765AF'  # Stef Walter
              '462225C3B46F34879FC8496CD605848ED7E69871') # Daiki Ueno

prepare() {
  cd p11-kit

  # Build and install an additional library (libnssckbi-p11-kit.so) which
  # is a copy of p11-kit-trust.so but uses the same label for root certs as
  # libnssckbi.so ("Builtin Object Token" instead of "Default Trust")
  # https://bugs.freedesktop.org/show_bug.cgi?id=66161
  patch -Np1 -i ../0001-Build-and-install-libnssckbi-p11-kit.so.patch

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd p11-kit
  ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --enable-doc \
    --with-module-path=/usr/lib/pkcs11 \
    --with-trust-paths=/etc/ca-certificates/trust-source:/usr/share/ca-certificates/trust-source
  make
}

check() {
  cd p11-kit
  make check
}

package() {
  cd p11-kit
  make DESTDIR="$pkgdir" install
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING

  ln -srf "$pkgdir/usr/bin/update-ca-trust" "$pkgdir/usr/lib/p11-kit/trust-extract-compat"
}

# vim:set ts=2 sw=2 et:
